package com.yc.RSS.Reader;

import com.yc.RSS.bean.CommonInformationItem;
import com.yc.RSS.bean.RSSDataCapturer;
import com.yc.RSS.buffer.NewsBuffer;
import org.apache.log4j.Logger;

import java.util.List;

public class NewsProductTask implements Runnable{
    private String name;
    private String url;
    private NewsBuffer newsBuffer;

    private Logger log=Logger.getLogger(NewsProductTask.class.getName());

    public NewsProductTask(String name, String url, NewsBuffer newsBuffer) {
        this.name = name;
        this.url = url;
        this.newsBuffer = newsBuffer;
    }

    @Override
    public void run(){
        RSSDataCapturer capturer=new RSSDataCapturer(name);
        List<CommonInformationItem> list=capturer.load(url);
        //存到缓存队列中
        for (CommonInformationItem item:list){
            newsBuffer.add(item);
        }
        log.info("下载："+name+"源的"+url+"的新闻成功");

    }
}
